﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QByteArray>
#include <QTimer>
#include <QFileDialog>
#include <QDataStream>
#include <QByteArray>
#include <QScreen>
#include <QDebug>
#include <QComboBox>
#include <QLineEdit>

namespace GX_LINK
{
    namespace SpaceMap
    {
        enum : int
        {
            code32_data96 = 0,
            code64_data64 = 1,
            code96_data32 = 2,
        };
    }
    namespace FreqInverse
    {
        enum : int
        {
            EMPTY       = 0,
            FREQ4       = 1,
            FREQ8       = 2,
            FREQ16      = 3,
            FREQ32      = 4,
            FREQ64      = 5,
            FREQ128     = 6,
            FREQ256     = 7,
            FREQ512     = 8,
            FREQ1024    = 9,
        };
    }

}

#define ComboBoxFreq(text2) comboBox_freq_##text2
#define LineEdit(text2) lineEdit_##text2
#define RESERVE_SPACE 0
#define DATA_RESERVE_SPACE 192

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void refresh_DataSize_all(const QString &text);
    void on_pushButton_clicked();
    void refresh_DataSize();
    void comboBox_freq_group_0_currentIndexChanged(int index);
    void comboBox_freq_group_1_currentIndexChanged(int index);
    void comboBox_freq_group_2_currentIndexChanged(int index);
    void comboBox_freq_group_3_currentIndexChanged(int index);
    void on_comboBox_size_currentIndexChanged(int index);

private:
    void readTxt(QString file);
    uint32_t reverseBits(uint32_t n);
    bool generate_Code(QString filename);
    void refreshDPI();
    void changeObjectSize(const QObject &o, double objectRate);
    Ui::MainWindow *ui;
    QLineEdit * remain_main_freq[4];
    QComboBox * combo_box_freq[64];
    QLineEdit * line_edit_space[64];

    int code_space_size[3] = {32*1024-RESERVE_SPACE, 64*1024-RESERVE_SPACE, 96*1024-RESERVE_SPACE};
    int data_space_size[3] = {96*1024-DATA_RESERVE_SPACE, 64*1024-DATA_RESERVE_SPACE, 32*1024-DATA_RESERVE_SPACE};
};
#endif // MAINWINDOW_H
